<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2025/5/25
  Time: 21:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>商品类别管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/index.css">
    <link type="text/css" rel="stylesheet" href="css/base.css">
</head>
<body>


<div class="container">
    <jsp:include page="header.jsp"></jsp:include>
    <div class="main category-list">

        <form class="category-add" method="post" action="/admin/category_add">
            <input type="text" id="category-name" name="name" placeholder="请输入商品类别名称" required="required">
            <button type="submit">添加类别</button>
        </form>

        <table>
            <thead>
            <tr>
                <th>ID</th>
                <th>类别名称</th>
                <th>是否启用</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${categoryList}" var="t">
                <tr>
                    <td>${t.id}</td>
                    <td>${t.name}</td>
                    <td>
                        <c:choose>
                            <c:when test="${t.is_use=='true'}">是</c:when>
                            <c:otherwise>否</c:otherwise>
                        </c:choose>
                    </td>
                    <td class="table-actions">
<%--                        商品类别id和编码后的商品名称,是否启用传过去--%>
                        <button class="edit-btn" onclick="location.href='/admin/category_edit.jsp?id=${t.id}&name=${t.encodeName}&is_use=${t.is_use}'">修改</button>
<%--                        <button class="edit-btn" onclick="location.href='/admin/category_edit.jsp?id=${t.id}&name=${t.encodeName }'">修改</button>--%>
                        <button class="delete-btn" onclick="location.href='/admin/category_delete?id=${t.id }'">删除</button>
                    </td>
                </tr>
            </c:forEach>

            </tbody>
        </table>
    </div>
</div>


</body>
</html>
